#ifndef _FLAYOUTINTERFACE_H_
#define _FLAYOUTINTERFACE_H_

namespace Font
{

	class DecorateLayout;

	class InterfaceLayout
	{

		friend class DecorateLayout;
	
	public:
	
		InterfaceLayout();
		~InterfaceLayout();

		virtual void SetFont(FaceHandle* a_Font) = 0;

	protected:
	
		virtual void _OnInstructionNewLine(tb::Vec2& a_Cursor, const TextCommand& a_Data) = 0;
		virtual void _OnInstructionTab(tb::Vec2& a_Cursor, const TextCommand& a_Data) = 0;

		virtual void _OnGlyphKerning(tb::Vec2& a_Cursor, GlyphEntry* a_Entry) = 0;
		virtual void _OnGlyphTransform(tb::Vec2& a_Cursor, GlyphQuad& a_Quad, GlyphEntry* a_Entry) = 0;
		virtual bool _OnGlyphAdd(tb::Vec2& a_Cursor, GlyphEntry* a_Entry) = 0;
	
	}; // class InterfaceLayout

	class DecorateLayout : public InterfaceLayout
	{
	
	public:
	
		DecorateLayout(InterfaceLayout* a_InterfaceDown);
		~DecorateLayout();

		virtual void SetFont(FaceHandle* a_Font);
	
	protected:

		virtual void _OnInstructionNewLine(tb::Vec2& a_Cursor, const TextCommand& a_Data);
		virtual void _OnInstructionTab(tb::Vec2& a_Cursor, const TextCommand& a_Data);

		virtual void _OnGlyphKerning(tb::Vec2& a_Cursor, GlyphEntry* a_Entry);
		virtual void _OnGlyphTransform(tb::Vec2& a_Cursor, GlyphQuad& a_Quad, GlyphEntry* a_Entry);
		virtual bool _OnGlyphAdd(tb::Vec2& a_Cursor, GlyphEntry* a_Entry);

		InterfaceLayout* m_InterfaceDown;
	
	}; // class DecorateLayout

	class LayoutBase : public InterfaceLayout
	{
	
	public:
	
		LayoutBase();
		~LayoutBase();

		void SetFont(FaceHandle* a_Font);

		void SetTabWidth(unsigned int a_Spaces);
	
	protected:

		void _OnInstructionNewLine(tb::Vec2& a_Cursor, const TextCommand& a_Data);
		void _OnInstructionTab(tb::Vec2& a_Cursor, const TextCommand& a_Data);

		void _OnGlyphKerning(tb::Vec2& a_Cursor, GlyphEntry* a_Entry);
		void _OnGlyphTransform(tb::Vec2& a_Cursor, GlyphQuad& a_Quad, GlyphEntry* a_Entry);
		bool _OnGlyphAdd(tb::Vec2& a_Cursor, GlyphEntry* a_Entry);

		FaceHandle* m_Font;
		wchar_t m_GlyphPrevious;

		unsigned int m_TabWidth;
		float m_TabLength;
	
	}; // class LayoutBase

}; // namespace Font
	
#endif